//
// Created by Criinal Nicole on 2020/6/17.
//

#include <cstring>
#include "FileIndexNode.h"

FILE_INDEX_NODE::FileIndexNode FILE_INDEX_NODE::fileIndexNodes[MAX_FILE_INDEX_NUM];

void FILE_INDEX_NODE::init() {
    memset(fileIndexNodes, 0, sizeof(fileIndexNodes));
    auto &root = fileIndexNodes[0];
    root._iAlloc = 1;
    root._posInDictionaryBlock = 0;
    root._ownerPri = 7;
    root._othersPri = 7;
    root._userId = 0;
    root._posInDictionaryBlock = MAX_FILE_INDEX_NUM;
    strcpy(root._Name, (char *) "root");
    for (int i = 0; i < MAX_FILE_INDEX_NUM; ++i) {
        auto &q = fileIndexNodes[i];
        q._nextInode = i + 1;
        if (i + 1 >= MAX_FILE_INDEX_NUM)q._nextInode = -1;
    }
}

